package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.JobDayExamine;
import com.ruoyi.system.mapper.JobDayExamineMapper;
import com.ruoyi.system.service.JobDayExamineService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 日审核表(JobDayExamine)表服务实现类
 *
 * @author makejava
 * @since 2022-11-23 09:20:08
 */
@Service("jobDayExamineService")
public class JobDayExamineServiceImpl implements JobDayExamineService {
    @Resource
    private JobDayExamineMapper jobDayExamineDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobDayExamine queryById(Integer id) {
        return this.jobDayExamineDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobDayExamine 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobDayExamine> queryByPage(JobDayExamine jobDayExamine, PageRequest pageRequest) {
        long total = this.jobDayExamineDao.count(jobDayExamine);
        return new PageImpl<>(this.jobDayExamineDao.queryAllByLimit(jobDayExamine, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobDayExamine> queryAll(JobDayExamine jobDayExamine) {
        return jobDayExamineDao.queryAll(jobDayExamine);
    }

    /**
     * 新增数据
     *
     * @param jobDayExamine 实例对象
     * @return 实例对象
     */
    @Override
    public JobDayExamine insert(JobDayExamine jobDayExamine) {
        this.jobDayExamineDao.insert(jobDayExamine);
        return jobDayExamine;
    }

    /**
     * 修改数据
     *
     * @param jobDayExamine 实例对象
     * @return 实例对象
     */
    @Override
    public JobDayExamine update(JobDayExamine jobDayExamine) {
        this.jobDayExamineDao.update(jobDayExamine);
        return this.queryById(jobDayExamine.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobDayExamineDao.deleteById(id) > 0;
    }
}
